/*
  ID: nemokin1
  PROG: dualpal
  LANG: C++
*/

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=b;--i)
#define FOREACH(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define ALL(c) (c).begin(),(c).end()
 
#define debug(x) cerr<< #x << " = " << (x) << "\n";
#define debugv(v) cerr << #v << " = "; FOREACH(it,v) cerr << *it <<","; cerr << "\n";
#define SIZE(a)  (int(a.size()))
 
template<typename T> inline void checkMax(T& a, T b) {if (b>a) a=b;}
template<typename T> inline void checkMin(T& a, T b) {if (b<a) a=b;}
 
typedef long long LL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef long double ld;
const int INF = 1000000000;

char ii[] = {'0','1','2','3','4','5','6','7','8','9','A',\
	     'B','C','D','E','F','G','H','I','G','K'
};
    
string i2s(int base, int num)
{
    if(num == 0) return "";
    else
    	return i2s(base,num/base)+ii[num%base];
}

int main() {
    freopen("dualpal.in","r",stdin);freopen("dualpal.out","w",stdout);
    int N,num;
    VI ret;
    int cnt = 0;
    
    cin >> N >> num;
    for(int i = num+1; ; i++){
	int tot = 0;
	
	for(int base = 2; base <= 10; base++){
	    string rev = i2s(base,i);
	    string ver(rev.rbegin(),rev.rend());
	    if(rev == ver) {
		tot++;
	    }
	    
	    if(tot == 2){
		ret.push_back(i);
		cnt++;
		break;
	    }
	}
	if(cnt == N) break;
    }

    REP(i,SIZE(ret)){
	cout<<ret[i]<<endl;
    }
    
    
}
    
